//设备管理
var deviceManage1 = echarts.init(document.getElementById('deviceManage1'));
var deviceManage2 = echarts.init(document.getElementById('deviceManage2'));
var deviceManage3 = echarts.init(document.getElementById('deviceManage3'));

function deviceChart1(data) {
    return {
        tooltip: {
            trigger: 'item',
            axisPointer: {
                type: 'cross',
                label: {
                    backgroundColor: '#6a7985'
                }
            }
        },
        title: {
            text: '设备在线率',
            x: 'center',
            'bottom': "20px",
            textStyle: {
                fontWeight: 'normal',
                color: "#fff",
                fontSize: 12
            }
        },
        "series": [
            {
                "center": [
                    "50%",
                    "50%"
                ],
                "radius": [
                    "78%",
                    "80%"
                ],
                "clockWise": false,
                "hoverAnimation": false,
                "type": "pie",
                "itemStyle": {
                    "normal": {
                        "label": {
                            "show": true,
                            'formatter': function (param) {
                                //console.log(name,"8888888888888")
                                //return '创优项目数\n\n' + 7;

                                if (param.dataIndex == 0) {
                                    if (data.totalDevices == 0) {
                                        return '0%'
                                    } else {
                                        return parseFloat(data.totalOnlineDevices * 100 / data.totalDevices).toFixed(2) + '%'
                                    }
                                } else return ''
                            },
                            "textStyle": {
                                "fontSize": 15,
                                "fontWeight": "bold"
                            },
                            "position": "center"
                        },
                        "labelLine": {
                            "show": false
                        },
                        "color": "#5886f0",
                        "borderColor": "#5886f0",
                        "borderWidth": 5
                    },
                    "emphasis": {
                        "label": {
                            "textStyle": {
                                "fontSize": 15,
                                "fontWeight": "bold"
                            },
                            "show": false,
                        },
                        "color": "#5886f0",
                        "borderColor": "#5886f0",
                        "borderWidth": 10
                    }
                },
                "data": [
                    {
                        "value": data.totalOnlineDevices,
                        "name": "在线"
                    },
                    {
                        "name": "离线",
                        "value": data.totalDevices - data.totalOnlineDevices,
                        "itemStyle": {
                            "normal": {
                                "label": {
                                    "show": false
                                },
                                "labelLine": {
                                    "show": false
                                },
                                "color": "#fe0c1b",
                                "borderColor": "#fe0c1b",
                                "borderWidth": 0
                            },
                            "emphasis": {
                                "color": "#fe0c1b",
                                "borderColor": "#fe0c1b",
                                "borderWidth": 0
                            }
                        }
                    }
                ]
            }
        ]
    };
}


function deviceChart2(data) {
    return {
        tooltip: {
            trigger: 'item',
            axisPointer: {
                type: 'cross',
                label: {
                    backgroundColor: '#6a7985'
                }
            }
        },
        title: {
            text: '随手拍完成率',
            x: 'center',
            'bottom': "20px",
            textStyle: {
                fontWeight: 'normal',
                color: "#fff",
                fontSize: 12
            }
        },
        "series": [
            {
                "center": [
                    "50%",
                    "50%"
                ],
                "radius": [
                    "78%",
                    "80%"
                ],
                "clockWise": false,
                "hoverAnimation": false,
                "type": "pie",
                "itemStyle": {
                    "normal": {
                        "label": {
                            "show": true,
                            'formatter': function (param) {
                                //console.log(name,"8888888888888")
                                //return '创优项目数\n\n' + 7;

                                if (param.dataIndex == 0) {
                                    if (data.totalCounts == 0) {
                                        return '0%'
                                    } else {
                                        return parseFloat(data.finish * 100 / data.totalCounts).toFixed(2) + '%'
                                    }
                                } else return ''
                            },
                            "textStyle": {
                                "fontSize": 15,
                                "fontWeight": "bold"
                            },
                            "position": "center"
                        },
                        "labelLine": {
                            "show": false
                        },
                        "color": "#5886f0",
                        "borderColor": "#5886f0",
                        "borderWidth": 5
                    },
                    "emphasis": {
                        "label": {
                            "textStyle": {
                                "fontSize": 15,
                                "fontWeight": "bold"
                            },
                            "show": false,
                        },
                        "color": "#5886f0",
                        "borderColor": "#5886f0",
                        "borderWidth": 10
                    }
                },
                "data": [
                    {
                        "value": data.finish,
                        "name": "完成"
                    },
                    {
                        "name": "未完成",
                        "value": data.totalCounts - data.finish,
                        "itemStyle": {
                            "normal": {
                                "label": {
                                    "show": false
                                },
                                "labelLine": {
                                    "show": false
                                },
                                "color": "#fe0c1b",
                                "borderColor": "#fe0c1b",
                                "borderWidth": 0
                            },
                            "emphasis": {
                                "color": "#fe0c1b",
                                "borderColor": "#fe0c1b",
                                "borderWidth": 0
                            }
                        }
                    }
                ]
            }
        ]
    }
}


function deviceChart3(data) {
    return {
        tooltip: {
            trigger: 'item',
            axisPointer: {
                type: 'cross',
                label: {
                    backgroundColor: '#6a7985'
                }
            }
        },
        title: {
            text: '整改完成率',
            x: 'center',
            'bottom': "20px",
            textStyle: {
                fontWeight: 'normal',
                color: "#fff",
                fontSize: 12
            }
        },
        "series": [
            {
                "center": [
                    "50%",
                    "50%"
                ],
                "radius": [
                    "78%",
                    "80%"
                ],
                "clockWise": false,
                "hoverAnimation": false,
                "type": "pie",
                "itemStyle": {
                    "normal": {
                        "label": {
                            "show": true,
                            'formatter': function (param) {
                                //console.log(name,"8888888888888")
                                //return '创优项目数\n\n' + 7;
                                if (param.dataIndex == 0) {
                                    if (data.totalCounts == 0) {
                                        return '0%'
                                    } else {
                                        return parseFloat(data.finish * 100 / data.totalCounts).toFixed(2) + '%'
                                    }
                                } else return ''
                            },
                            "textStyle": {
                                "fontSize": 15,
                                "fontWeight": "bold"
                            },
                            "position": "center"
                        },
                        "labelLine": {
                            "show": false
                        },
                        "color": "#5886f0",
                        "borderColor": "#5886f0",
                        "borderWidth": 5
                    },
                    "emphasis": {
                        "label": {
                            "textStyle": {
                                "fontSize": 15,
                                "fontWeight": "bold"
                            },
                            "show": false,
                        },
                        "color": "#5886f0",
                        "borderColor": "#5886f0",
                        "borderWidth": 10
                    }
                },
                "data": [
                    {
                        "value": data.finish,
                        "name": "完成"
                    },
                    {
                        "name": "未完成",
                        "value": data.totalCounts - data.finish,
                        "itemStyle": {
                            "normal": {
                                "label": {
                                    "show": false
                                },
                                "labelLine": {
                                    "show": false
                                },
                                "color": "#fe0c1b",
                                "borderColor": "#fe0c1b",
                                "borderWidth": 0
                            },
                            "emphasis": {
                                "color": "#fe0c1b",
                                "borderColor": "#fe0c1b",
                                "borderWidth": 0
                            }
                        }
                    }
                ]
            }
        ]
    }
}




